const http = require('http');
const port = process.env.PORT || 3000;

http.createServer((req, res) => {
    const path = req.url.replace(/\/?(?:\?.*)?$/, '');
    res.writeHead(200, {'Content-Type': 'text/plain'});
    switch (path) {
        case '/':
            res.end('Welcome to the homepage');
            break;
        case '/about':
            res.end('About us');
            break;
        case '/contact':
            res.end('Contact us');
            break;
        default:
            res.statusCode = 404;
            res.end('Page not found');
    }
}).listen(3000, () => {
    console.log(`Server is running on port ${port}`);
    console.log('Press Ctrl+C to stop the server');
});

